
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Mr Bao
 */
public class UpAnhForm extends Form implements CommandListener {

    private UpAnh upAnh;
    private TextField txtName;
    private Command cmdSend = new Command("Up", Command.OK, 2);
    private Command cmdBack = new Command("Back", Command.BACK, 2);
    private byte[] images;
    private boolean isCamera;

    public UpAnhForm(UpAnh upAnh, byte[] images, boolean isCamera) {
        super("Up Anh");
        this.upAnh = upAnh;
        this.images = images;
        this.isCamera = isCamera;
        txtName = new TextField("Ten anh", null, 50, TextField.ANY);
        this.append(txtName);
        this.addCommand(cmdSend);
        this.addCommand(cmdBack);
        this.setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d) {
        if (c == cmdSend) {
            upAnh.client.SendImage(txtName.getString(), images);
            if (isCamera) {
                upAnh.DisplayCamera();
            } else {
                upAnh.DisplayBrowserBack();
            }
        }
        if (c == cmdBack) {
            if (isCamera) {
                upAnh.DisplayCamera();
            } else {
                upAnh.DisplayBrowserBack();
            }
        }
    }
}
